package com.xique.door.controller;

import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.door.bean.request.buildElevator.BuildElevatorAddRequest;
import com.xique.door.bean.request.buildElevator.BuildElevatorAllListRequest;
import com.xique.door.bean.request.buildElevator.BuildElevatorEditRequest;
import com.xique.door.bean.request.buildElevator.BuildElevatorListRequest;
import com.xique.door.bean.request.elevator.ElevatorAllListRequest;
import com.xique.door.biz.service.IBuildElevatorBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author shd
 * @create 2022/3/29 9:46
 */
@RestController
@RequestMapping("/community/elevator")
public class BuildElevatorController extends BaseController {

    @Autowired
    private IBuildElevatorBizService elevatorBizService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "door:elevator:list")
    @GetMapping("/list")
    public AjaxResult list(BuildElevatorListRequest request)
    {
        return elevatorBizService.getElevatorList(request);
    }

    @PreAuthorize(hasPermi = "door:elevator:add")
    @Log(title = "电梯信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Valid BuildElevatorAddRequest request) {
        return elevatorBizService.addElevator(request);
    }

    @PreAuthorize(hasPermi = "door:elevator:query")
    @GetMapping("/detail")
    public AjaxResult detail(Long id) {
        return elevatorBizService.getElevatorDetail(id);
    }

    @PreAuthorize(hasPermi = "door:elevator:edit")
    @Log(title = "电梯信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody @Valid BuildElevatorEditRequest request) {
        return elevatorBizService.editElevator(request);
    }

    @PreAuthorize(hasPermi = "door:elevator:remove")
    @Log(title = "电梯信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public AjaxResult remove(Long id) {
        return elevatorBizService.removeElevator(id);
    }

    @PreAuthorize(hasPermi = "door:elevator:list")
    @GetMapping("/allList")
    public AjaxResult allList(@Valid BuildElevatorListRequest request) {
        return elevatorBizService.getAllElevatorList(request);
    }
}
